/**
 * @Description: 类型定义
 * @Author: mofish
 * @Date: 2022-05-27
 * @LastEditTime: 2022-05-27
 * @LastEditors: mofish
 */
 import { RouteObject } from 'react-router-dom'

 interface MetaType {
   [propName: string]: any
 }
 
 interface FunctionalImportType {
   (): any
 }
 
 type ReactElementType = JSX.Element
 
 interface RoutesItemType extends RouteObject {
   redirect?: string
   component?: FunctionalImportType
   meta?: MetaType
   children?: RoutesItemType[]
 }
 
 type RoutesType = RoutesItemType[]
 
 type OneOfResType = string | void
 
 type BeforeRouteEnterResType = OneOfResType | Promise<OneOfResType> | ReactElementType
 
 interface BeforeRouteEnterType {
   (payload: {
     pathname: string
     meta: MetaType
   }): BeforeRouteEnterResType
 }
 
 interface EasyRoutePropsType {
   routes: RoutesType
   beforeRouteEnter?: BeforeRouteEnterType
   loading?: ReactElementType
 }
 
 interface EasyRouterType {
   (payload: EasyRoutePropsType): JSX.Element
 }
 
 export type {
   MetaType, // 路由meta字段类型
   FunctionalImportType, // 懒加载函数式导入组件的类型
   ReactElementType, // react组件实例元素类型
   RoutesItemType, // 路由配属数组项类型
   RoutesType, // 路由配置数组类型
   OneOfResType, // 路由拦截函数返回值中的一种类型
   BeforeRouteEnterResType, // 路由拦截函数（实际有效使用的）返回值类型
   BeforeRouteEnterType, // 路由拦截函数类型
   EasyRoutePropsType, // EasyRouter 主组件props类型
   EasyRouterType, // EasyRouter主组件类型
 }
 
 declare const EasyRouter: EasyRouterType
 
 export default EasyRouter